//
//  QDMainPageStationCollectionViewCell.m
//  QDMetroClient
//
//  Created by YueWen on 2019/2/21.
//  Copyright © 2019 YueWen. All rights reserved.
//

#import "QDMPStationCollectionViewCell.h"

@implementation QDStationView

- (instancetype)initWithFrame:(CGRect)frame {
    
    if (self = [super initWithFrame:frame]) {
        
        self.startLabel = ({
            
            UILabel *label = [UILabel new];
            label.backgroundColor = [UIColor whiteColor];
            label.text = @"李村公园";
            label.font = RITLSemiboldFont(isSmallerScreen() ? 14 : 16);
            label.textColor = QDSColorDefaultBlack;
            
            label;
        });
        
        self.arrowImageView = ({
            
            UIImageView *imageView = [UIImageView new];
            imageView.backgroundColor = UIColor.whiteColor;
            imageView.contentMode = UIViewContentModeScaleAspectFill;
            imageView.image = @"mp_st_arrow_right".ritl_image;
            
            imageView;
        });
        
        self.endLabel = ({
            
            UILabel *label = [UILabel new];
            label.backgroundColor = [UIColor whiteColor];
            label.text = @"芝泉路";
            label.font = RITLSemiboldFont(isSmallerScreen() ? 14 : 16);
            label.textColor = QDSColorDefaultBlack;
            
            label;
        });
        
        self.timeLabel = ({
            
            UILabel *label = [UILabel new];
            label.backgroundColor = [UIColor whiteColor];
            label.text = @"首06:20  末22:52 ";
            label.font = RITLLightFont(12);
            label.textColor = RITLColorSimpleFromIntRBG(102);
            
            label;
        });
        
        [self addSubview:self.startLabel];
        [self addSubview:self.arrowImageView];
        [self addSubview:self.endLabel];
        [self addSubview:self.timeLabel];
         
        [self.startLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.top.offset(0);
            make.height.mas_lessThanOrEqualTo(22);
        }];
        
        [self.arrowImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.startLabel.mas_right).offset(isSmallerScreen() ? 2 : 10);
            make.centerY.equalTo(self.startLabel);
            make.height.width.mas_equalTo(10);
        }];
        
        [self.endLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.arrowImageView.mas_right).offset(isSmallerScreen() ? 2 : 10);
            make.centerY.equalTo(self.startLabel);
            make.height.mas_lessThanOrEqualTo(22);
        }];
        
        [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.startLabel.mas_bottom);
            make.height.mas_lessThanOrEqualTo(16);
            make.left.offset(0);
        }];
    }
    
    return self;
}



@end

@implementation QDMPStationCollectionViewCell

- (void)buildView {
    [super buildView];
    
    self.lineLabel = ({
        
        UILabel *label = [UILabel new];
        label.backgroundColor = RITLColorFromIntRBG(237, 116, 69);
        label.text = @"2";
        label.textAlignment = NSTextAlignmentCenter;
        label.layer.cornerRadius = 4;
        label.clipsToBounds = true;
        label.font = RITLSemiboldFont(28);
        label.textColor = UIColor.whiteColor;
        
        label;
    });
    
    self.subLabel = ({
        
        UILabel *label = [UILabel new];
        label.backgroundColor = [UIColor whiteColor];
        label.text = @"号 线";
        label.font = RITLMediumFont(12);
        label.textColor = QDSColorDefaultBlack;
        
        label;
    });
    
    self.endLabel = ({
        
        UILabel *label = [UILabel new];
        label.backgroundColor = [UIColor whiteColor];
        label.text = @"Line 2";
        label.font = RITLMediumFont(9);
        label.textColor = QDSColorDefaultBlack;
        
        label;
    });
    
    self.comeLineView = ({
        [QDStationView new];
    });
    
    self.backLineView = ({
        [QDStationView new];
    });
    
    [self.contentView addSubview:self.lineLabel];
    [self.contentView addSubview:self.subLabel];
    [self.contentView addSubview:self.endLabel];
    [self.contentView addSubview:self.comeLineView];
    [self.contentView addSubview:self.backLineView];
    
    [self.lineLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.mas_equalTo(40);
        make.left.offset(isSmallerScreen() ? 16 : 20);
        make.top.offset(0);
    }];
    
    [self.subLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.lineLabel.mas_right).offset(4);
        make.height.mas_equalTo(17);
        make.top.offset(5);
    }];
    
    [self.endLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.subLabel);
        make.top.equalTo(self.subLabel.mas_bottom);
        make.height.mas_equalTo(13);
    }];
    
    [self.comeLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(0);
        make.left.offset(isSmallerScreen() ? 115 : 131);
        make.right.inset(10);
        make.height.mas_equalTo(39);
    }];
    
    [self.backLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.comeLineView.mas_bottom).offset(154 - 129 - 17);
        make.left.offset(isSmallerScreen() ? 115 : 131);
        make.right.inset(10);
        make.height.mas_equalTo(39);
    }];
}

- (UIImageView *)imageView {
    return nil;
}

@end
